package com.simon.hse.activity.safe.jobticket.commonly;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.simon.hse.R;
import com.simon.hse.activity.BaseActivity;
import com.simon.hse.adapter.CommonEmptyAdapter;
import com.simon.hse.adapter.CommonViewHolder;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

/**
 * 钢丝绳和吊钩检查表
 */
@SuppressWarnings("all")
@ContentView(R.layout.activity_commonly_gangsisheng)
public class CommonlyGangsishengActivity extends BaseActivity {
    @ViewInject(R.id.tv_common_title)
    TextView mTv_common_title;

    @ViewInject(R.id.iv_common_right)
    ImageView mIv_common_right;

    @ViewInject(R.id.recyclerview_qzj)
    RecyclerView mRecyclerview_qzj;

    private boolean isShowMore = false;// 是否展示更多筛选框

    @ViewInject(R.id.ll_message_more)
    LinearLayout mLl_message_more;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mTv_common_title.setText("钢丝绳和吊钩检查表");
        mIv_common_right.setVisibility(View.GONE);
        initQzj();
    }

    @Event(value = {R.id.iv_common_left, R.id.tv_train_record_confirm, R.id.tv_train_record_cancel, R.id.ll_msg_more, R.id.tv_message_more_reset
            , R.id.tv_message_more_confirm, R.id.iv_add})
    private void clickButton(View view) {
        switch (view.getId()) {
            case R.id.iv_common_left:
                finish();
            case R.id.tv_train_record_confirm:
                finish();
                break;
            case R.id.tv_train_record_cancel:
                finish();
            case R.id.ll_msg_more:
                if (isShowMore) {
                    mLl_message_more.setVisibility(View.GONE);
                } else {
                    mLl_message_more.setVisibility(View.VISIBLE);
                }
                isShowMore = !isShowMore;
                break;
            case R.id.tv_message_more_reset:
                mLl_message_more.setVisibility(View.GONE);
                isShowMore = !isShowMore;
                break;
            case R.id.tv_message_more_confirm:
                mLl_message_more.setVisibility(View.GONE);
                isShowMore = !isShowMore;
                break;
            case R.id.iv_add:
                startActivity(new Intent(CommonlyGangsishengActivity.this, CommonlyGangsishengDetailActivity.class));
                break;
        }
    }

    /**
     * 机械移动式起重机外观检查表
     */
    private void initQzj() {
        List<String> mList = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            mList.add("第" + i + "条数据");
        }
        LinearLayoutManager llm = new LinearLayoutManager(CommonlyGangsishengActivity.this);
        mRecyclerview_qzj.setLayoutManager(llm);
        // 如果Item够简单，高度是确定的，打开FixSize将提高性能
        mRecyclerview_qzj.setHasFixedSize(true);
        // 设置Item默认动画，加也行，不加也行
        mRecyclerview_qzj.setItemAnimator(new DefaultItemAnimator());
        mRecyclerview_qzj.setNestedScrollingEnabled(false);

        CommonEmptyAdapter mCommonEmptyAdapter = new CommonEmptyAdapter(CommonlyGangsishengActivity.this, R.layout.layout_commonly_qizhongji_item, mList);
        mCommonEmptyAdapter.setItemDataListener(new CommonEmptyAdapter.ItemDataListener<String>() {
            @Override
            public void setItemData(CommonViewHolder holder, String dataBean) {
                // TextView tv_law_msg = holder.getView(R.id.tv_law_msg);

            }
        });

        mCommonEmptyAdapter.setOnItemEmptyClickListener(new CommonEmptyAdapter.OnItemEmptyClickListener() {
            @Override
            public void setOnEmptyClickListener() {

            }

            @Override
            public void setOnItemClickListener(View view, int position) {

            }

            @Override
            public void setOnItemLongClickListener(View view, int position) {

            }
        });

        mCommonEmptyAdapter.setHasStableIds(true);
        mRecyclerview_qzj.setAdapter(mCommonEmptyAdapter);
    }
}
